package com.lc.afbx.conn;

import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONArray;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2016/5/28.
 */
@HttpInlet(Conn.INLET_API_INTEGRAL_MALL)
public class GetJiFenShangCheng extends BaseAsyGet<GetJiFenShangCheng.Info> {
    public GetJiFenShangCheng(AsyCallBack<GetJiFenShangCheng.Info> asyCallBack) {
        super(asyCallBack);
    }

    protected Info parser(JSONObject jsonObject) {

        TOAST = jsonObject.optString("message");
        if (jsonObject.optInt("code") == 200) {

            JSONArray array = jsonObject.optJSONArray("data");

            Info info = new Info();
            for (int i = 0; i < array.length(); i++) {


                JSONObject o = array.optJSONObject(i);
                Data d = new Data();

                d.id = o.optString("id");
                d.goodsname = o.optString("goodsname");
                d.picurl = Conn.PIC + o.optString("picurl");
                d.integral = o.optString("integral");

                info.data.add(d);
            }
            return info;
        }
        return null;
    }

    public static class Info {
        public List<Data> data = new ArrayList<>();
    }

    public static class Data {
//        "id": "1",
//                "goodsname": "加油卡",
//                "picurl": "",
//                "integral": "30000"

        public String id, goodsname, picurl, integral;
    }
}
